home *** CD-ROM | disk | FTP | other *** search
- /* MakeIndex
- Hacked by Andy Macklin to produce a sort of index of doc/guide files.
- My version of grep uses the following syntax...
- usage: grep [-[[AB] ]<num>] [-[CEFGVchilnqsvwx]] [-[ef]] <expr> [<files...>]
-
- Requirements: grep
- sort
- copy
- searchguide (optional)
- same syntax as buildindex (optional)
-
- */
-
- buildidx='Y' /*Change to 'Y' for an all in one script ;) */
- SGUIDE='Y' /*Change to 'Y' for an automatic search button in the docs guide file */
-
- address command
-
- Volume = GetVar('AACD')
-
- /* Clear icon position */
- ';nopos' Volume':disk nodd'
- /* Delete trashcan */
- ';delete >NIL: 'Volume':Trashcan all force'
- ';delete >NIL: 'Volume':T all force'
-
- /* defines and such */
- /* GREP CALL */
- GREPCALL = "grep"
- /* GREP HELP CALL */
- GREPHELP = "grep -h"
- /* Where's the CD index? */
- IDXLOC = Volume':CDTools/indices/'Volume
- /* Where's the finished guide to go to?*/
- outfile = Volume':CDTools/Docs.guide'
- /* Path to MultiView */
- MView = Volume':System/Utilities/MultiView'
- /* Extensions to search for */
- Extensions = 'guide|doc|dok|txt|text|asc|man|readme'
-
- if buildidx='Y' then do
- /* NB the column format is important for the sort fuction later */
- 'delete >NIL:' outfile /* Otherwise the guide will contain a reference to itself */
- 'delete >NIL:' IDXLOC
- 'list ' Volume':~(html|images|System|Trashcan|S|T) all files pat=~(#?.info) lformat "%-33N%P%N" to' IDXLOC
- ';list ' Volume':AACD all files pat=~(#?.info) lformat "%-33N%P%N" >>'IDXLOC
- ';list ' Volume':AACD/~(WWW) all files pat=~(#?.info) lformat "%-33N%P%N" >>'IDXLOC
- ';list' Volume':AACD/WWW all files pat=~(#?.info) lformat "%-33N%P%N" >>'IDXLOC
- end
-
- grepfile = "t:grepoutput." || Pragma("i")
- agfile = "t:grepguide." || Pragma("i")
- CR = d2c(10)
- TAB = d2c(9)
-
- /* setup the output file - we need this first so we can show errors in it */
- IF Open(agfp,agfile,'w') = 0 THEN DO
- SAY "Couldn't create amigaguide file ("||agfile||")"
- EXIT 20
- END
-
- call writeln(agfp,'@DATABASE "CD docs"')
- call writeln(agfp,'@REMARK created by Andys MakeIndex v2 :)')
- call writeln(agfp,'')
- call writeln(agfp,'@NODE Main "DOCS & GUIDES"')
- call writeln(agfp,'')
-
- /* Put a search button (needs searchguide in the CDs path) */
- if SGUIDE='Y' then do
- call writeln(agfp,'@{" Search " SYSTEM "RUN 'Volume':CDTools/SearchGuide/SearchGuide '||substr(outfile,pos(':',outfile)+1)||'" }')
- call writeln(agfp,'')
- end
-
- SIGNAL ON FAILURE
- ADDRESS COMMAND
- 'delete >NIL:' grepfile
- do until Extensions = ''
- parse var Extensions ext '|' Extensions
- GREPCALL '-F .'ext IDXLOC '>>' grepfile
- end
- 'rename' grepfile ' to ' grepfile||'.old'
- 'sort' grepfile||'.old' grepfile 'colstart 37'
- SIGNAL OFF FAILURE
-
- IF Open(grepfp,grepfile,'r') = 0 THEN DO
- CALL HandleError("Couldn't open grep output file ("||grepfile||")","")
- END
-
- /*************************************************************************
- ** Format of Grep output
- ** =====================
- **
- **HTMLit!.guide AACD4:Magazine/WiredWorld/HTMLit!/HTMLit!.guide
- **DemosOfTheWorld.guide AACD4:AACD/Demos/DemosOfTheWorld/DemosOfTheWorld.guide
- **mc12.guide AACD4:AACD/Demos/Malevolent_Creations/mc12.guide
- **iml-Feb71.guide AACD4:AACD/Graphics/Imagine/iml-Feb71.guide
- **Dust.guide AACD4:AACD/Graphics/Imagine/Dust/Docs/Dust.guide
- **DustEnglish.guide AACD4:AACD/Graphics/Imagine/Dust/Docs/DustEnglish.guide
- **IM_Organizer.guide AACD4:AACD/Graphics/Imagine/IM_Organiser/IM_Organizer.guide
- **TextureStudio.guide AACD4:AACD/Graphics/Imagine/TextureStudio/Docs/TextureStudio.guide
- **ncFTPevents.guide AACD4:AACD/Online/ThorStuff/Programs/ncFTPevents/Thor/docs/ncFTPevents.guide
- **
- ****************************************************************************/
-
- line = ReadLn(grepfp)
- IF EOF(grepfp) THEN DO
- call close(grepfp)
- say 'No files found'
- exit 10
- END
-
-
- CALL Pragma('W','n') /* turn off dos requesters */
-
- DO WHILE ~EOF(grepfp)
- /* START BY LOOKING FOR FILENAMES */
- currentfile = Strip(Left(line,Length(Word(line,1))),"B")
- location = strip(right(line,length(line)-length(word(line,1))),"B")
- if right(currentfile,5) ='guide' then
- do
- node='/main'
- action='link "'
- end
- else
- do
- node=''
- action='system "'MView' '
- end
- endif
- call writeln(agfp,'@{" 'currentfile left('',33-length(currentfile))' "' action||location||node'" } 'substr(location,pos(':',location)+1))
- line = ReadLn(grepfp)
- END
-
- call WriteLn(agfp,'@ENDNODE')
-
- call Close(grepfp)
- call Close(agfp)
-
- CALL Pragma('W','w') /* turn dos requesters back on */
-
- address command
- 'copy' agfile outfile
- 'delete >NIL:' grepfile
- 'delete >NIL:' grepfile||'.old'
- 'delete >NIL:' agfile
-
- EXIT
-
- FAILURE:
- ERROR:
- errRC = RC
- CALL Close(grepfp)
- CALL HandleError("Grep Failure:"|| CR || " " || FullCommand ,grepfile)
- EXIT
-
- /***************************************************/
- HandleError: PROCEDURE EXPOSE agfp grepfile agfile grephelp
-
- ErrorText = arg(1)
- ErrorFile = arg(2)
-
- call writeln(agfp,'-=-=-=-=-=-=-=-=-= E R R O R =-=-=-=-=-=-=-=-=-')
- call writeln(agfp,ErrorText)
- call writeln(agfp,' ')
-
- IF (ErrorFile~="" & Exists(ErrorFile)) THEN DO
- call writeln(agfp,"Response:")
- ADDRESS COMMAND GREPHELP '>>'ErrorFile
- Open('errorfp',ErrorFile,'r')
- DO WHILE ~EOF('errorfp')
- call writeln(agfp," " || ReadLn('errorfp'))
- END
- call close('errorfp')
- END
-
- call writeln(agfp,"")
- call writeln(agfp,"Current Path:")
- call writeln(agfp," "||Pragma("D"))
- call writeln(agfp,'@ENDNODE')
-
- call close(agfp)
-
- IF Exists(grepfile) THEN Delete(grepfile)
- Delete(agfile)
-
- EXIT 20
- RETURN
-
-